home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / VOXRAY.ZIP / RAYFILE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-24  |  3.3 KB  |  169 lines

  1. #ifndef _RAYFILE_
  2. #define _RAYFILE_
  3.  
  4. #include <string.h>
  5. #include <fstream.h>
  6. #include "ray.h"
  7. #include "globals.h"
  8. #include "filetype.h"
  9.  
  10. #define RESOURCE_LENGTH 8
  11. #define F_NUM_TYPES 10
  12.  
  13. extern "C++" BOOL world_loaded;
  14. extern "C++" BOOL wall_tex_loaded;
  15. extern "C++" BOOL floor_tex_loaded;
  16. extern "C++" BOOL sound_loaded;
  17. extern "C++" fstream fp;
  18. extern "C++" WFHeader header;
  19. extern "C++" dir_entry * directory;
  20. extern "C++" short base_index;
  21. extern "C++" BOOL binary_mode;
  22. extern "C++" void * cur_table;
  23.  
  24. BOOL Cmp_Str_N(char * s1, char * s2, short n);
  25. void F_Clear_World();
  26. void F_Clear_WT();
  27. void F_Clear_FT();
  28. void F_Clear_Sky();
  29. void F_Clear_Sound();
  30. void F_Load_World();
  31. void F_Get_Wall_Textures();
  32. void F_Get_Floor_Textures();
  33. void F_Get_Sky();
  34. void F_Get_Vectors();
  35. void F_Get_SDs();
  36. void F_Get_LDs();
  37. void F_Get_Segs();
  38. void F_Get_SSectors();
  39. void F_Get_Sectors();
  40. void F_Get_Objects();
  41. void F_Get_Object_Types();
  42. void F_Get_BSP();
  43. void Load_Vox_Map(PUCHAR & vox_ptr, long offset);
  44. void F_Get_Sound();
  45. void F_Setup(char * filename);
  46. void F_Close();
  47. void F_Get_Dir();
  48. void F_Seek(long offset);
  49. short F_Find_And_Setup(char * string, void ** table, short memsize);
  50. SHORT F_Find_Dir(char * name);
  51. void F_D_Setup(char * filename);
  52. void F_D_Load_World();
  53. void F_D_Get_Vectors();
  54. void F_D_Get_SDs();
  55. void F_D_Get_LDs();
  56. void F_D_Get_Segs();
  57. void F_D_Get_SSectors();
  58. void F_D_Get_Sectors();
  59. void F_D_Get_BSP();
  60. void F_D_Get_Player_Loc();
  61. void Doom_Sort_SSector(ssector * cur_ss);
  62. void Swap_Segs(seg * base_seg, seg * swap_seg);
  63.  
  64. inline void F_Go_To_Next_Line()
  65. {
  66. if (!binary_mode) { 
  67.   char ch;
  68.   fp >> ch;
  69.   while (ch=='#') {
  70.     fp.ignore(-1, '\n');
  71.     fp >> ch;
  72.     }
  73.   fp.putback(ch);
  74.   }
  75. }
  76.  
  77. inline void F_Get_Long(long & value)
  78. {
  79. F_Go_To_Next_Line();
  80. if (binary_mode)
  81.   fp.read((char *)&value, sizeof(long));
  82. else fp >> value;
  83. }
  84.  
  85. inline void F_Get_Short(short & value)
  86. {
  87. F_Go_To_Next_Line();
  88. if (binary_mode)
  89.    fp.read((char *)&value, sizeof(short));
  90. else fp >> value;
  91. }
  92.  
  93. inline void F_Get_UShort(USHORT & value)
  94. {
  95. F_Get_Short((short &)value);
  96. }
  97.  
  98. inline void F_Get_ULong(ULONG & value)
  99. {
  100. F_Get_Long((long &)value);
  101. }
  102.  
  103. inline void F_Get_Byte(Byte & value)
  104. {
  105.  
  106. F_Go_To_Next_Line();
  107. if (binary_mode) {
  108. fp >> value;
  109. } else {
  110. short temp_value;
  111. fp >> temp_value;
  112. value=(Byte)temp_value;
  113. }
  114.  
  115. }
  116.  
  117. inline void F_Get_String(char * str, short length)
  118. {
  119. F_Go_To_Next_Line();
  120. if (binary_mode)
  121.   fp.read(str, length);
  122. else { 
  123.   fp >> str;
  124.   short counter=(short)strlen(str);
  125.   for (;counter<length; counter++)
  126.     str[counter]=' ';
  127.   }
  128. }
  129.  
  130. inline void F_Get_String_NT(char * str, short length)
  131. {
  132. F_Go_To_Next_Line();
  133. if (binary_mode) {
  134.    fp.read(str, length);
  135. } else {
  136.    fp >> str;
  137.    } /* endif */
  138. }
  139.  
  140. inline void F_Get_Bool(BOOL & value) {
  141. if (binary_mode) {
  142.    Byte byte_res;
  143.    F_Get_Byte(byte_res);
  144.    if (byte_res) {
  145.       value=TRUE;
  146.    } else {
  147.       value=FALSE;
  148.    }
  149. } else {
  150.    CHAR string_res [BOOL_NAME_LENGTH];
  151.    F_Get_String_NT(string_res,BOOL_NAME_LENGTH);
  152.    if (!strnicmp(string_res, "TRUE", BOOL_NAME_LENGTH)) {
  153.       value=TRUE;
  154.    } else {
  155.       value=FALSE;
  156.    }
  157. }
  158. }
  159.  
  160. inline long F_Abs_Pos() {
  161.    return fp.tellg();
  162. }
  163.  
  164. inline void F_Seek_Abs(long pos) {
  165.    fp.seekg(pos, ios::beg);
  166. }
  167.  
  168. #endif
  169.